package com.augurit.wf.common.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.augurit.common.base.action.ExtCrudActionSupport;
import com.augurit.common.system.web.auth.form.LoginUserForm;
import com.augurit.wf.common.service.ISelectUserService;
import com.augurit.wf.common.util.WfUtils;
import com.augurit.wf.jbpmex.assignee.AssigneeTreeNode;

/**
 * 工作流Action类
 */
@SuppressWarnings("serial")
public class AssigneeRangeTreeAction extends ExtCrudActionSupport<AssigneeTreeNode> {

	@Autowired
	private ISelectUserService selectUserService;

	private String assigneeRange;
	private String taskInstDbid;
	private AssigneeTreeNode form;
	private String keyword;
	
	
	public String getTaskInstDbid() {
		return taskInstDbid;
	}

	public void setTaskInstDbid(String taskInstDbid) {
		this.taskInstDbid = taskInstDbid;
	}

	public String loadData() throws Exception{
		LoginUserForm uform=(LoginUserForm)this.getRequest().getSession().getAttribute("SES_LOGIN_USER");
		List<AssigneeTreeNode> result = selectUserService.getChildrenByKeyword(form, assigneeRange, keyword,uform,taskInstDbid);
		
		this.extRenderListJson(result, false);
		return null;
	}

	public String getAllOrgsByKeyword() throws Exception{
		List<AssigneeTreeNode> result = selectUserService.getAllOrgsByKeyword(form, keyword);
		this.renderXml(WfUtils.renderXmlForAssigneeTreeNode(result));
		return null;
	}
	
	public String getAllRolesByKeyword() throws Exception{
		List<AssigneeTreeNode> result = selectUserService.getAllRolesByKeyword(form, keyword);
		this.renderXml(WfUtils.renderXmlForAssigneeTreeNode(result));
		return null;
	}
	
	public String getAllPositionsByKeyword() throws Exception{
		List<AssigneeTreeNode> result = selectUserService.getAllPositionsByKeyword(form, keyword);
		this.renderXml(WfUtils.renderXmlForAssigneeTreeNode(result));
		return null;
	}

	public AssigneeTreeNode getModel() {
		return form;
	}

	@Override
	protected void prepareModel() throws Exception {
		form = new AssigneeTreeNode();
	}
	
	
	public AssigneeTreeNode getForm() {
		return form;
	}

	public void setForm(AssigneeTreeNode form) {
		this.form = form;
	}

	public String getAssigneeRange() {
		return assigneeRange;
	}

	public void setAssigneeRange(String assigneeRange) {
		this.assigneeRange = assigneeRange;
	}


	@Override
	public String delete() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public String list() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public String save() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}


	public String getKeyword() {
		return keyword;
	}


	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}
	
}
